﻿using System;
using System.Collections.Generic;

namespace SFJDManagement
{
    public static class TypeExtends
    {
        /// <summary>
        /// 获取从服务组发送至用户界面的任务ID
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int GetDictianaryKey(this Type type)
        {
            //Dictionary<int, Type> dictionary = new DictionaryInitialize().GetDictionary();
            foreach (KeyValuePair<int, Type> kvp in Runtime.dictionary)
            {
                if (kvp.Value.Equals(type))
                {
                    return kvp.Key;
                }
            }
            return -32767;
        }

        /// <summary>
        /// 获取从用户界面发送至服务组的任务ID
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int GetClient2ServerKey(this Type type)
        {
            foreach (KeyValuePair<int, Type> kvp in Runtime.dictionary)
            {
                if (kvp.Value.Equals(type))
                {
                    return kvp.Key - 20000;
                }
            }
            return -32767;
        }
    }
}
